import { OrderUserAddressType } from './../types/user'
import http from '@/utils/request'

/**
 * 获取结算信息
 */
export const findCheckoutInfo = () =>
  http({
    url: '/member/order/pre'
  })

/**
 * 添加收货地址
 */
export const addAddress = (data: OrderUserAddressType) =>
  http({
    url: '/member/address',
    method: 'post',
    data
  })

/**
 * 编辑收货地址信息
 */
export const editAddress = (data: OrderUserAddressType) =>
  http({
    url: `/member/address`,
    method: 'put',
    data
  })

/**
 * 提交订单
 */
export const createOrder = (data: any) =>
  http({
    url: '/member/order',
    method: 'post',
    data
  })

/**
 * 获取订单详情
 */
export const findOrder = (id: string) =>
  http({
    url: `/member/order/${id}`
  })
